package com.jgp.glmeeting.mobile.controller;

import com.jgp.glmeeting.mobile.commons.BaseResponse;
import com.jgp.glmeeting.mobile.commons.ErrorMsg;
import com.jgp.glmeeting.model.Inform;
import com.jgp.glmeeting.service.InformService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("mobile/MobileInformController")
public class MobileInformController {

    private final Logger logger = LoggerFactory.getLogger(MobileInformController.class);

    @Autowired
    private InformService informService;

    /**
     * 查询通知信息接口
     * @param meetingId
     * @param participantsId
     * @return
     */
    @RequestMapping("queryInformInfos")
    public BaseResponse queryInformInfos(String meetingId, String participantsId) {
        if(StringUtils.isBlank(meetingId) || StringUtils.isBlank(participantsId)){
            return new BaseResponse(ErrorMsg.INVALID_PARAM.getCode(), ErrorMsg.INVALID_PARAM.getErrorMsg());
        }
        try {
            BaseResponse baseResponse = new BaseResponse(200);
            List<Inform> informList = informService.queryListByMeetingIdAndParticipantsId(meetingId, participantsId);
            baseResponse.setObj(informList);
            return baseResponse;
        }catch (Exception e) {
            logger.error("查询通知信息接口异常,meetingId={}, participantsId={}",meetingId,participantsId,e);
            return new BaseResponse(ErrorMsg.SERVER_ERROR.getCode(), ErrorMsg.SERVER_ERROR.getErrorMsg());
        }
    }
}
